Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

105
Visualizações
Fire "data-ng-change" programatically or another way to change value of input on website using Angular JS

I am writing a userscript and unfortunately the website uses Angular JS which I don't know.

There is code:

<form class="form ng-pristine ng-valid ng-valid-maxlength" name="$ctrl.actionableForm.form" _lpchecked="1">
<input type="text" maxlength="254" placeholder="" data-ng-attr-id="text-field-{{:: $ctrl.widget.header.id }}" data-ng-model="$ctrl.fieldValue.value" data-ng-change="$ctrl.updateFormFieldValue()" data-ng-blur="$ctrl.onBlur()" data-ng-focus="$ctrl.updateFormFieldValue()" data-ng-readonly="$ctrl.isReadOnly()" data-ng-trim="false" data-ng-keyup="$ctrl.handleKeyup($event)" class="form-control text-field-input ng-pristine ng-untouched ng-valid ng-not-empty ng-valid-maxlength focus-visible" id="text-field-qYMHEJMncH0S-ogeOc5CTw" data-focus-visible-added="">

I want to change the value of that input programatically, like:

document.querySelector('[id^="text-field-"]').value = 'My new value';

But it doesn't work because it doesn't fire data-ng-change="$ctrl.updateFormFieldValue()" so the new value is not saved.

Please how can I do it?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If someone will look for the same thing, I solved it this way:

const myField = document.querySelector('[id^="text-field-"]');
myField.value = 'My new value';
angular.element(myField).trigger('change');
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda